<%@ Page Language="C#" MasterPageFile="~/FiledbookMaster.Master" AutoEventWireup="true" CodeBehind="StorageOverview.aspx.cs" Inherits="Fieldbook.Testwebsite.User.StorageOverview" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function ShowHideDiv(on, elemID)
        {
            var divElem = document.getElementById(elemID);
            if (on)
            {
                divElem.style.display = "block";
            }
            else 
            {
                divElem.style.display = "none";
            }
            return false;
        }
    </script>

    <a href="#" onclick="return ShowHideDiv(true, 'divAddResouceCategory')">Add resource category</a> |
    <a href="#" onclick="return ShowHideDiv(true, 'divAddResource')">Add resource type</a>
    
    <br />
    <br />
    <asp:Label ID="lblOperationStatus" runat="server" EnableViewState="false"/>
    <div id="divAddResouceCategory" style="display:none;">
        <table>
            <tr>
                <td>Description: </td>
                <td>
                    <asp:TextBox ID="txtResourceCategory" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:LinkButton id="LinkButton1" runat="Server" OnCommand="linkAddCategory_Command" Text="Add"/>
                    <asp:LinkButton id="LinkButton2" runat="Server" 
                        OnCommand="linkAddCategory_Command" 
                        CommandArgument="global"
                        Text="Add global"/>
                    <a href="#" onclick="return ShowHideDiv(false, 'divAddResouceCategory')">Cancel</a>
                </td>
            </tr>
        </table>   
        <br/ />
    </div>
    
    <div id="divAddResource" style="display:none;">
        <table>
            <tr>
                <td>Category:</td>
                <td>
                    <asp:DropDownList ID="ddlResourceCategory" runat="Server" DataSourceID="ResouceCategoriesODS" 
                        DataTextField="Description" 
                        DataValueField="CategoryID"/>
                </td>
            </tr>
            <tr>
                <td>Measure unit:</td>
                <td>
                    <asp:DropDownList ID="ddlMeasureUnit" runat="Server" DataSourceID="MeasureUnitsODS" 
                        DataTextField="Description" 
                        DataValueField="MeasureUnitID"/>                
                </td>
            </tr>
            <tr>
                <td>Description:</td>
                <td>
                    <asp:TextBox ID="txtResource" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:LinkButton id="addResource" runat="Server" OnCommand="linkAddResource_Command" Text="Add"/>
                    <asp:LinkButton id="addGlobalResource" runat="Server" 
                        OnCommand="linkAddResource_Command" 
                        CommandArgument="global"
                        Text="Add global"/>
                    <a href="#" onclick="return ShowHideDiv(false, 'divAddResource')">Cancel</a>
                </td>
            </tr>
        </table>
        <br />
    </div>
   
    <asp:GridView ID="dgvCategories" runat="server" AutoGenerateColumns="False" 
                  DataSourceID="ResouceCategoriesODS" 
                  DataKeyNames="CategoryID"
                  OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
        </Columns>
    </asp:GridView>
    <br />
    <asp:GridView ID="dgvStorage" runat="server" AutoGenerateColumns="false" 
        OnRowDataBound="dgvStorage_RowDataBound" >
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>
                    Resource
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label runat="Server" ID="ResourceID" Text='<%# Eval("ResourceID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Quota" HeaderText="Quota" SortExpression="Quota" />
        </Columns>
    </asp:GridView>
    <br />
    
    <asp:ObjectDataSource ID="ResouceCategoriesODS" runat="server" TypeName="Fieldbook.Business.ResourceController" SelectMethod="LoadResourceCategories">
        <SelectParameters>
            <asp:SessionParameter Name="userID" Type="Int64" SessionField="userID" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="MeasureUnitsODS" runat="server" TypeName="Fieldbook.Business.MeasureUnitController" SelectMethod="LoadAllMeasureUnits"/>
</asp:Content>
